#!/bin/sh

DEST_ROOT=/data

#i=0

#while [ $i -lt 5 ]
while [ 1 ]
do
  DEST_DIR=$DEST_ROOT/`date +%y%m%d`/`date +%H`
  STAMP=`date +%y%m%d_%H%M%S`

  if [ ! -d $DEST_DIR ]
  then
      mkdir -p $DEST_DIR
  fi

  ./dackel -t100000000 -m 5000 -r 15 -z3 -o/data/delme.dkl -l$DEST_DIR/$STAMP.log $*

  if [ $? -ne 0 ]
  then
#			sleep 5;
#			./load_module
#			sleep 5;
#			./load_module
#			sleep 5;
      echo -e "\n----------------------\nERROR, last log file: $DEST_DIR/$STAMP.log"
      exit;
  fi
  
#  ((i++));

done

echo -e "\n************************************************\nNO ERRORS\n\n";